package com.qudian.pay.notify.dingtalk.demo;

import java.util.ArrayList;
import org.junit.Test;
import com.qudian.pay.notify.dingtalk.DingtalkChatbotClient;
import com.qudian.pay.notify.dingtalk.SendResult;
import com.qudian.pay.notify.dingtalk.message.TextMessage;

public class TextMessageTest {
	
	private DingtalkChatbotClient client = new DingtalkChatbotClient();
	
	@Test
	public void testSendTextMessage() throws Exception {
		TextMessage message = new TextMessage("李彪，你家着火了");
		SendResult result = client.send(WebhookConfig.testWebhook, message);
		System.out.println(result);
	}
	
	@Test
	public void testSendTextMessageWithAt() throws Exception {
		TextMessage message = new TextMessage("我就是我, 是不一样的烟火");
		ArrayList<String> atMobiles = new ArrayList<String>();
		atMobiles.add("137xxxx3310");
		message.setAtMobiles(atMobiles);
		SendResult result = client.send(WebhookConfig.testWebhook, message);
		System.out.println(result);
	}
	
	@Test
	public void testSendTextMessageWithAtAll() throws Exception {
		TextMessage message = new TextMessage("我就是我, 是不一样的烟火");
		message.setIsAtAll(true);
		SendResult result = client.send(WebhookConfig.testWebhook, message);
		System.out.println(result);
	}
	
	@Test
	public void testSendTextMessageWithAtAndAtAll() throws Exception {
		TextMessage message = new TextMessage("我就是我, 是不一样的烟火");
		ArrayList<String> atMobiles = new ArrayList<String>();
		atMobiles.add("186xxxx0822");
		message.setAtMobiles(atMobiles);
		message.setIsAtAll(true);
		SendResult result = client.send(WebhookConfig.testWebhook, message);
		System.out.println(result);
	}
}